<?php
class Deal_category_model extends MY_Model {
	
	var $name = null;
	var $code = null;
	var $description = null;
	
	public function __construct() {
		parent::__construct();
	}

	public function find_by_code($code) {
		$sql = "SELECT * FROM " . $this->table() . " WHERE valid = ? AND code = ?";
		return $this->db->query($sql, array(1,$code))->result_object();
	}
	
	public function find_by_code_of_others($id, $code) {
		$sql = "SELECT * FROM " . $this->table() . " WHERE valid = ? AND code = ? AND id != ?";
		return $this->db->query($sql, array(1,$code,$id))->result_object();
	}
}